<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="/statics/layui/css/layui.css" media="all">
</head>

<body>

  <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
    <legend>我的项目投资</legend>
  </fieldset>
  <table class="layui-hide" id="dg" lay-filter="dg"></table>
  <script type="text/html" id="barStatus">
  {{#  if(d.status == 0){ }}
    <span style="color:gray;">进行中</span>
  {{#  } else { }}
    <span style="color:green;">已发币</span>
  {{#  } }}  
</script>
  <script src="/statics/layui/layui.js" charset="utf-8"></script>
  <script type="text/javascript" src="../js/jquery-1.11.0.min.js"></script>
  <script type="text/javascript" src="../js/config.js"></script>
  <script type="text/javascript" src="../js/utils.js"></script>
  <script>
    layui.use(['table', 'element'], function () {
      var table = layui.table, element = layui.element;

      table.render({
        elem: '#dg'
        , url: Config.WEB_SERVER_API + Config.URI.USER_MONEY_PROJECT_LIST,
        request: {
          pageName: 'offset' //页码的参数名称，默认：page
          , limitName: 'limit' //每页数据量的参数名，默认：limit
        },
        cellMinWidth: 80, //全局定义常规单元格的最小宽度，layui 2.2.1 新增
        cols: [[
          { field: 'id', title: 'ID', hide: true }
          , { fixed: 'left', field: 'projectName', title: '项目名称', width: 150 }
          , { fixed: 'left', field: 'orderId', title: '订单号', width: 190 }
          , { fixed: 'left', field: 'statusName', title: '状态', width: 80, toolbar: '#barStatus' }
          , { field: 'typeName', title: '投资币种', width: 100 }
          , { field: 'money', title: '投资数量', width: 100 }
          , { field: 'brokeMoney', title: '手续费', width: 100, templet: function (d) { return '<span style="color:green;">'+(d.brokeMoney||0)+'</span>'; } }
          , { field: 'realMoney', title: '实际数量', width: 100, templet: function (d) { return '<span style="color:red;">'+(d.realMoney||0)+'</span>'; } }
          , { field: 'projectMoney', title: '投资币种数量', width: 120, templet: function (d) { return (d.projectMoney||0) + (d.project ? d.project.moneyTypeName : ''); } }
          , { field: 'sendMoney', title: '已发币数量', width: 120, templet: function (d) { return '<span style="color:green;">'+(d.sendMoney||0)+'</span>'; } }
          , { field: 'createTime', title: '投资时间', width: 160, templet: function (d) { return FormatUtils.parseTimestampToDateTime(d.createTime); } }
          , { field: 'sendTime', title: '发币时间', width: 160, templet: function (d) { return FormatUtils.parseTimestampToDateTime(d.sendTime); } }


          // ,{ fixed: 'right', title: '操作', toolbar: '#bar', width: 150 }
        ]]
        , page: true, loading: true,
        response: {
          statusCode: "200" //重新规定成功的状态码为 200，table 组件默认为 0
        },
        parseData: function (res) { //将原始数据解析成 table 组件所规定的数据
          return {
            "code": parseInt(res.resultCode), //解析接口状态
            "msg": res.resultMsg, //解析提示文本
            "count": res.total, //解析数据长度
            "data": res.rows //解析数据列表
          };
        }
      });

    });

  </script>

</body>

</html>